package xyz.poke.business.tool.exception;

import lombok.Data;
import lombok.EqualsAndHashCode;
import xyz.poke.business.tool.common.ErrorCode;

/**
 * @author 迫壳
 * @date 2024/3/3 21:17
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class BusinessException  extends RuntimeException {

    /**
     * 错误码
     */
    private final int errorCode;

    /**
     * 错误信息
     */
    private final String msg;

    public BusinessException(ErrorCode errorCode) {
        this.errorCode = errorCode.getCode();
        this.msg = errorCode.getMessage();
    }

    public BusinessException(int errorCode, String msg) {
        this.errorCode = errorCode;
        this.msg = msg;
    }

    public BusinessException(String msg) {
        this.errorCode = ErrorCode.FAIL.getCode();
        this.msg = msg;
    }

}
